home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-09 | 3.2 KB | 107 lines | [TEXT/MPS ] |
- {*******************************************************************************
- UDateTimeUtilities.p
- This file contains the implementations of a number of routines which help
- make the Script Manager more useable.
- *******************************************************************************}
-
- UNIT UDateTimeUtilities;
-
- INTERFACE
- USES
- { • MacApp }
- UMacApp,
- UMacAppUtilities,
-
- { • Implementation use }
- ToolUtils,
- Packages,
- Script;
-
- CONST
- kNotADate = -0; { a comp NaN (a LongDateTime is a comp) }
- kNotATime = $FFFFFFFF; { the maximum unsigned longint value }
-
- kWantSeconds = TRUE; { for time to string operations }
- kDontWantSeconds = FALSE; { for time to string operations }
-
- kSecsPerMinute = 60; { number of seconds in a minute }
- kSecsPerHour = 60 * kSecsPerMinute; { seconds in a hour }
- kSecsPerDay = 24 * kSecsPerHour; { seconds in a day }
-
- {###########################################################################
- Initialization
- This routine MUST be called to initialize this unit. Call it AFTER
- MacApp has been initialized. When it is initialized relative to the
- other MacApp building blocks does not matter.
- ###########################################################################}
-
- PROCEDURE InitUDateTimeUtilities;
-
-
- {###########################################################################
- Global Routines
- In these routines, a LongDateTime is used to represent a date in a
- compact form, while a LONGINT is used to represent a time in a compact
- form.
-
- In both cases, a LongDateRec is used to represent the type's expanded
- form.
- ###########################################################################}
-
- PROCEDURE InitLongDateRec(
- VAR dateRec: LongDateRec;
- toValue: INTEGER);
- { Places the given value in each field of the given rec }
-
- PROCEDURE SecsToRec(
- dateSecs: LongDateTime;
- VAR dateRec: LongDateRec);
- { Makes the given LongDateRec match the given LongDateTime. }
-
- PROCEDURE RecToSecs(
- VAR dateRec: LongDateRec; { not changed }
- VAR dateSecs: LongDateTime);
- { Makes the given LongDateTime match the given LongDateRec. }
-
- PROCEDURE DateToString(
- dateSecs: LongDateTime;
- theDateForm: DateForm;
- VAR theDate: Str255);
- { Makes the given string match the given LongDateTime. }
-
- PROCEDURE TimeToString(
- timeSecs: LONGINT;
- wantSeconds: BOOLEAN;
- VAR theTime: Str255);
- { Makes the given string match the given time. }
-
- FUNCTION StringToDate(
- dateStr: Str255;
- VAR dateSecs: LongDateTime)
- :String2DateStatus;
- { Makes the given LongDateTime match the given string. }
-
- FUNCTION StringToTime(
- timeStr: Str255;
- VAR timeSecs: LONGINT)
- :String2DateStatus;
- { Makes the given time match the given string. }
-
- FUNCTION LongDateTimeToTime(
- VAR dateSecs: LongDateTime)
- :LONGINT;
- { This routine extracts the current time from the given LongDateTime. }
-
- PROCEDURE GetCurrentDate(
- VAR dateSecs: LongDateTime);
- { Returns today's date. }
-
- PROCEDURE GetCurrentTime(
- VAR timeSecs: LONGINT);
- { Returns the current time. }
-
- IMPLEMENTATION
-
- {$I UDateTimeUtilities.inc1.p}
-
- END. { UDateTimeUtilities.p }